home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / Demos_Files / DLL / InputPrepost.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  2.3 KB  |  81 lines

  1. // Dynamic link library implementation of a generic input source
  2.  
  3. #include "NSDLL.h" 
  4.  
  5. #define data(i,j)        data[j+i*cols]
  6.  
  7. /***************************/
  8. /* Activation of component */
  9. __declspec(dllexport) void performInput(
  10.     DLLData    *instance,    // Pointer to instance data (may be NULL)
  11.     NSFloat    *data,         // Pointer to the data
  12.     int rows,         // Number of rows of data
  13.     int cols         // Number of cols of data
  14.     )
  15. {
  16.     int i,j;
  17.     for (i=0; i<rows; i++)
  18.         for (j=0; j<cols; j++)
  19.             data(i,j) = 0.0f;    // You define your own input source.
  20. }
  21.  
  22. /******************************************/
  23. /* Management of instance data (OPTIONAL) */
  24. /*
  25. __declspec(dllexport) DLLData *allocInput(
  26.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  27.     int rows,         // Number of rows of data
  28.     int cols         // Number of cols of data
  29.     )
  30. {
  31.     DLLData *instance = allocDLLInstance(oldInstance);
  32.     return instance;
  33. }
  34.  
  35. __declspec(dllexport) void freeInput(DLLData *instance)
  36. {
  37.     freeDLLInstance(instance); 
  38. }
  39. */
  40.  
  41.  
  42. // Dynamic link library implementation of a generic pre/post-processor
  43.  
  44. #include "NSDLL.h" 
  45.  
  46. /***************************/
  47. /* Activation of component */
  48. __declspec(dllexport) BOOL performPrePost(
  49.     DLLData    *instance,    // Pointer to instance data (may be NULL)
  50.     NSFloat    *input,     // Pointer to the input data
  51.     NSFloat    *output,     // Pointer to the output data
  52.     int rows,         // Number of rows of data
  53.     int cols         // Number of cols of data
  54.     )
  55. {
  56.     int i, length=rows*cols;
  57.     for (i=0; i<length; i++)
  58.         output[i] += input[i];
  59.     return TRUE;    // Return whether to inject this sample or to call performPrePost with another sample
  60. }
  61.  
  62. /******************************************/
  63. /* Management of instance data (OPTIONAL) */
  64. /*
  65. __declspec(dllexport) DLLData *allocPrePost(
  66.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  67.     int *rows,         // Number of rows of output data, can be changed to reflect a diffenent number for the input data
  68.     int *cols,         // Number of cols of output data, can be changed to reflect a diffenent number for the input data
  69.     BOOL preprocessor    // Flag to indicate whether this is a preprocessor or postprocessor
  70.     )
  71. {
  72.     DLLData *instance = allocDLLInstance(oldInstance);
  73.     return instance;
  74. }
  75.  
  76. __declspec(dllexport) void freePrePost(DLLData *instance)
  77. {
  78.     freeDLLInstance(instance); 
  79. }
  80. */
  81.